package com.guobox.movies.proxy;

import android.text.TextUtils;

import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;

/**
 * Created by xuxinlei on 2017/7/13.
 */

public class Proxy_Nas {
    public static final String STATE = "err_code";
    public static final String OK = "0";
    public static final String BODY = "data";

    public static final String FILE = "film";
    public static final String SERIES = "series";

    public static JsonElement getContent(String responseJson) {
        if (TextUtils.isEmpty(responseJson)) {
            return null;
        }
        JsonParser jsonParser = new JsonParser();
        JsonElement responseJsonElement = null;
        try {
            responseJsonElement = jsonParser.parse(responseJson);
        } catch (JsonParseException e) {
            e.printStackTrace();
        }
        if (responseJsonElement == null) {
            return null;
        }
        if (responseJsonElement.getAsJsonObject().get(Proxy_Nas.STATE).getAsString().equals(Proxy_Nas.OK)) {
            return responseJsonElement.getAsJsonObject().get(Proxy_Nas.BODY);

        }
        return null;
    }
}
